using System.Collections;
using System.Collections.Generic;
using Assets.Common.Unity;
using UnityEngine;
using UnityEngine.Pool;
/// <summary>
/// 不可区分性对象池对象,使用时不区分池中物体.
/// </summary>
public class GameObjectPoolManager : MonoBehaviour
{
    private Dictionary<Transform, TransformPool> m_OriginalObjectIDs;
    private Dictionary<Transform, HashSet<Transform>> _instanceObjectSets;
    // public static Transform Instantiate(
    //     Transform original,
    //     int secondaryKey,
    //     Vector3 position,
    //     Quaternion rotation,
    //     Transform parent)
    // {
    //     return InstantiateInternal(original, secondaryKey, position, rotation, parent);
    // }

    private TransformPool CreatePool(Transform prefab)
    {
        var obj = new GameObject();
        var pool =  obj.AddComponent<TransformPool>();
        pool.SetPrefab(prefab);
        return pool;
    }
    private Transform InstantiateInternal(
        Transform original,
        int secondaryKey,
        Vector3 position,
        Quaternion rotation,
        Transform parent)
    {
        if (!this.m_OriginalObjectIDs.ContainsKey(original))
        {
            m_OriginalObjectIDs.Add(original,CreatePool(original)); 
        }

        if (m_OriginalObjectIDs.TryGetValue(original, out var objPool))
        {

        }
        else
        {
            var obj = objPool.Get();
            obj.position = position;
            obj.rotation = rotation;
            obj.SetParent(parent);
            // _instanceObjectSets.Add(original, obj);
        }

        return null;
    }
}
